<?php if(sizeof($products) > 0) { ?>
<div class="middle">
	<div style=" border: 1px solid #DDDDDD; width:750px;clear: both; height:23px;background-color: #F6F9FF";>
		<div  style="float: left;padding:6px;">
			Sắp xếp theo
		</div>
		<div style=" float: left;padding-left: 4px;">
	      <select name="sort" onchange="getCatalogData(this.value);" style="width:110px; padding-left: 4px;">
	        <?php foreach ($sorts as $sorts) { ?>
	        <?php if (($sort . '-' . $order) == $sorts['value']) { ?>
	        <option value="<?php echo $sorts['href']; ?>" selected="selected"><?php echo $sorts['text']; ?></option>
	        <?php } else { ?>
	        <option value="<?php echo $sorts['href']; ?>"><?php echo $sorts['text']; ?></option>
	        <?php } ?>
	        <?php } ?>
	      </select>
	    </div>
	    <div style="float: left;padding: 4px;">
			Khu vực bán
		</div>
		<div style="float: left;">
	      <select name="zone_id" id="zone_id" onchange="getCatalogData(this.value);">
	              <?php foreach ($areas as $area) { ?>
	              		<option value="<?php echo $this->url->http('product/category/ajax&path=' . $this->request->get['path'] . '&zone_id='.$area['zone_id']); ?>" <?php if( $zone_id == $area['zone_id']) echo "selected";?> > <?php echo $area['name']; ?></option>
	              <?php } ?>
	       </select>
	    </div>
  </div>
  <br/>
  <div id="review_title"></div>
  <?php if ($products) { ?>
  <div class="pagination"><?php echo $pagination; ?></div>
  <?php } ?>
  <div>
  <table class="catalog" style="width: 750px;">
  	<tr style="background-color: #DDFDDF;height: 25px;">
  		<td width="15%">
  		</td>
  		<td width="45%">
  		 	Tên sản phẩm
  		</td>
  		<td width="25%">
  			Giá
  		</td>
  		<td width="20%">
  			Phạm vi bán
  		</td>
  	</tr>
  <?php for ($i = 0; $i < sizeof($products); $i++) { ?>
  	<tr>
  		<td width="15%">
  			<a href="<?php echo $products[$i]['href']; ?>">
  				<img style="padding: 10px;" src="<?php echo $products[$i]['thumb']; ?>" width="120" height="120"/>
  			</a>
  		</td>
  		<td width="35%">
  			<h1>
  				<a style="margin-top: 10px;" href="<?php echo $products[$i]['href']; ?>"><?php echo $products[$i]['name']; ?></a>
  			</h1>
  			<h1 style="font-size: 11px; padding-top: 10px;">
  			Đăng bởi:
  			<?php if(isset($products[$i]['shop_name'])) {?>
  				<a href="<?php echo $products[$i]['href_shop'] ?>" >
  						<?php echo $products[$i]['shop_name'] ?>
  					</a>
  			<?php } ?>
  			</h1>
  			<h1 style="padding-top: 15px;">
  				<span style="color: #999; font-size: 11px;">
  					Ngày đăng:<?php echo $products[$i]['date_added']; ?> |
  				</span>
  				<span style="color: #999; font-size: 11px;">
  					Xem:<?php echo $products[$i]['viewed']; ?> |
  				</span>
  				<span style="color: #999; font-size: 11px;">
  					Comments:<?php echo $products[$i]['rating']; ?>
  				</span>
  			</h1>
  		</td>
  		<td width="15%">
	  		<?php if ($display_price) { ?>
	        		<?php if (!$products[$i]['special']) { ?>
	        			<span style="color: #900; font-weight: bold;"><?php echo $products[$i]['price']; ?>
	        			</span>
	        		<?php } else { ?>
	        			<span style="color: #900; font-weight: bold; text-decoration: line-through;">
	        			<?php echo $products[$i]['price']; ?>
	        			</span>
	        			<span style="color: #F00;">
	        				<?php echo $products[$i]['special']; ?>
	        			</span>
	        	<?php } ?>
	        <?php } ?>
  		</td>
  		<td width="20%">
  			<span style="font-size: 12px;">
  				<?php echo $products[$i]['zone']; ?>
  			</span>
  		</td>
  	</tr>
  <?php } ?>
  </table>
  </div>
  <?php if ($products) { ?>
  <div class="pagination" style="margin-top:6px;"><?php echo $pagination; ?></div>
  <?php } ?>
</div>
<?php } else { ?>
<div style="clear: both; height:23px;background-color: #DDDFFF">
	Không tìm thấy sản phẩm.
</div>
<?php } ?>

<style type="text/css">
	.catalog {
		border:1px solid #DDDFFF;
	}
	.catalog td {
		border-bottom:1px solid #DDDFFF;
		border-left: 1px solid #DDDDDD;
		border-right: 1px solid #DDDDDD;
		text-align: left;
		margin-top: 2px;
		padding-left: 10px;
	}
	.catalog tr td h1 {
		color: blue;
		margin-top: 1px;
		font-weight: lighter;
	}

	.catalog tr td h1 a {
		color:blue;
		margin-top: 1px;
		font-weight: lighter;
		font-size:11;
		text-decoration: none;
	}
</style>

<script type="text/javascript">
function getCatalogData(url) {
	$.ajax({
		type: 'post',
		url: url,
		dataType: 'json',
		beforeSend: function() {
			$('#review_title').after('<div style="width:740px; text-align: center;" class="wait">Hệ thống đang xử lý...<img src="catalog/view/theme/default/image/loading_1.gif" alt="" /></div>');
		},
		complete: function() {
		},
		success: function(data) {
			if (data.error) {
				$('#review_title').after('<div class="warning">' + data.error + '</div>');
			}
			if (data.success) {
				//$("#content").html("");
				$("#content").html(data.html);
			}
		}
	});
}

</script>